package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServicePay;
import com.ruoyi.service.service.IServicePayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支付信息表Controller
 * 
 * @author ZDL
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/service/pay")
public class ServicePayController extends BaseController
{
    @Autowired
    private IServicePayService servicePayService;

    /**
     * 查询支付信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:pay:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServicePay servicePay)
    {
        startPage();
        List<ServicePay> list = servicePayService.selectServicePayList(servicePay);
        return getDataTable(list);
    }

    /**
     * 导出支付信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:pay:export')")
    @Log(title = "支付信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicePay servicePay)
    {
        List<ServicePay> list = servicePayService.selectServicePayList(servicePay);
        ExcelUtil<ServicePay> util = new ExcelUtil<ServicePay>(ServicePay.class);
        util.exportExcel(response, list, "支付信息表数据");
    }

    /**
     * 获取支付信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:pay:query')")
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return success(servicePayService.selectServicePayByPayId(payId));
    }

    /**
     * 新增支付信息表
     */
    @PreAuthorize("@ss.hasPermi('service:pay:add')")
    @Log(title = "支付信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicePay servicePay)
    {
        return toAjax(servicePayService.insertServicePay(servicePay));
    }

    /**
     * 修改支付信息表
     */
    @PreAuthorize("@ss.hasPermi('service:pay:edit')")
    @Log(title = "支付信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicePay servicePay)
    {
        return toAjax(servicePayService.updateServicePay(servicePay));
    }

    /**
     * 删除支付信息表
     */
    @PreAuthorize("@ss.hasPermi('service:pay:remove')")
    @Log(title = "支付信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payIds}")
    public AjaxResult remove(@PathVariable Long[] payIds)
    {
        return toAjax(servicePayService.deleteServicePayByPayIds(payIds));
    }
}
